package note1.chapters.chapter3;

import java.util.Random;

public class MathOps {

	public static void main(String[] args) {
		// 随机数生成器对于相同的种子值总是产生相同的随机数序列
		Random random = new Random();
		int x = random.nextInt(100);
		int y = random.nextInt(100);
		System.out.println(x + ".." + y);
		int x2 = random.nextInt(100);
		int y2 = random.nextInt(100);
		System.out.println(x2 + ".." + y2);
		// 一元加号可以将较小类型的操作数提升为int
		short a = 9;
		// a = +a;
		System.out.println(1.0 == 1.00);
		// &&和||会有短路效应,&和|不会有短路效应
		System.out.println(false && ++a > 9);
		System.out.println(a);
		System.out.println(false & ++a > 9);
		System.out.println(a);
		int i3 = 0177;
		System.out.println(i3 + ":" + Integer.toBinaryString(i3));
		char d = 0x7fff;
		System.out.println(d + ":" + Integer.toBinaryString(d));
		char d2 = (char) -3;
		System.out.println(d2 + ":" + Integer.toBinaryString(d2));
		// <<低位补0，>>有符号右移，>>>无符号右移
		int e1 = 0xffffffff;
		e1 <<= 1;
		System.out.println(e1 + ":" + Integer.toBinaryString(e1));
		int e2 = 0xffffffff;
		e2 >>= 1;
		System.out.println(e2 + ":" + Integer.toBinaryString(e2));
		int e3 = 0xffffffff;
		e3 >>>= 1;
		System.out.println(e3 + ":" + Integer.toBinaryString(e3));
		System.out.println(4 * Integer.MAX_VALUE);
	}

}
